package main

import (
	"common"
	"demo1/rpc_server"
	"fmt"
	"github.com/gin-gonic/gin"
)

func init() {
	fmt.Println("start grpc server")
	go rpc_server.InitGrpc()
}

func main() {
	engine := gin.Default()
	client := common.InitETCD("demo1", "127.0.0.1", 8081, "1")
	engine.GET("/demo1/test", func(context *gin.Context) {
		context.JSON(200, gin.H{
			"message": "demo1 的Get 的请求",
		})
	})
	engine.POST("/demo1/test", func(context *gin.Context) {
		context.JSON(200, gin.H{
			"message": "demo1 的Post 的请求",
		})
	})
	engine.Run(":8081")
	defer client.Close()
}
